home *** CD-ROM | disk | FTP | other *** search
- #include<hold/anim.h>
-
- /* 000 */ void quicksorte(int [], int,int);
-
- /* 001 */ void user4_control(){
- /* 002 */ int d[10] = {-2,9,1,8,2,7,3,6,4,5};
- /* 003 */ int parts = 10;
-
- a_func("user4_control",1);
- a_irayini(d,"d",parts,2);
- a_intini(parts,"parts",3);
- a_show(4);
- /* 004 */ quicksorte(d,0,parts-1);
- a_endfunc("user4_control",5);
- /* 005 */ }
-
- /* 006 */ void quicksorte(int a[],int l,int r ){
- /* 007 */ int v,i,j,t;
-
- a_func("quicksorte",6);
- a_iraypas("a",6);
- a_intini(l,"l",6);
- a_intini(r,"r",6);
- a_intini(v,"v",7);
- a_intini(i,"i",7);
- a_intini(j,"j",7);
- a_intini(t,"t",7);
- a_intcomp("r>l",8);
- /* 008 */ if(r>l){
- /* 009 */ v=a[r];
- a_intass("v","a[r]",9);
- /* 010 */ i=l-1;
- a_intass("i","l-1",10);
- /* 011 */ j=r;
- a_intass("j","r",11);
- a_show(12);
- /* 012 */ for(;;){
- a_intass("i","i+1",13);
- a_intcomp("a[i]<v",13);
- /* 013 */ while(a[++i] < v){
- a_intass("i","i+1",13);
- a_intcomp("a[i]<v",13);
- /* 014 */ }
- a_intass("j","j-1",15);
- a_intcomp("a[j]>v",15);
- /* 015 */ while(a[--j] > v){
- a_intass("j","j-1",15);
- a_intcomp("a[j]>v",15);
- /* 016 */ }
- a_intcomp("i>=j",17);
- /* 017 */ if(i >= j) break;
- /* 018 */ t = a[i];
- a_intass("t","a[i]",18);
- /* 019 */ a[i] = a[j];
- a_intass("a[i]","a[j]",19);
- /* 020 */ a[j] = t;
- a_intass("a[j]","t",20);
- a_show(12);
- /* 021 */ }
- /* 022 */ t = a[i];
- a_intass("t","a[i]",22);
- /* 023 */ a[i] = a[r];
- a_intass("a[i]","a[r]",23);
- /* 024 */ a[r] = t;
- a_intass("a[r]","t",24);
- a_show(25);
- /* 025 */ quicksorte(a, l, i-1);
- a_show(26);
- /* 026 */ quicksorte(a, i+1,r);
- /* 027 */ }
- a_endfunc("quicksorte",28);
- /* 028 */ }
-
-